<template>
    <view>
        <cu-custom bgColor="bg-yellow2" :isBack="true">
            <block slot="content">新增乘车人</block>
        </cu-custom>

        <view class="cu-form-group min-height40">
            <view class="min-width75">姓名</view>
            <input placeholder="请输入真实姓名" name="input" v-model="name" />
        </view>
        
        <view class="cu-form-group min-height40 margin-top-xs justify-start">
            <view class="min-width75">证件类型</view>
            <view >身份证</view>
        </view>
        <view class="cu-form-group min-height40">
            <view class="min-width75">证件号码</view>
            <input placeholder="请与证件保持一致" name="input" v-model="icCard" />
        </view>
        <view class="padding-lr margin-top">
            <view class="flex">
                <text class="cuIcon-info text-orange self-start text-gray" style="margin: 2px"></text>
                <view class="padding-lr-xs text-sm">
                    点击确定表示您已阅读并同意以下内容
                </view>
            </view>
            <view class="text-sm text-gray">
                根据实名制要求，购买汽车票需提交乘客的身份证件信息，并需在乘车时出具对应身份证件用于验证，请确保录入信息真实有效。新登洛客运将通过加密等方式保护您录入的身份证件信息，且仅在具体订票过程中提供给与您进行交易的商户/承运人。
            </view>
        </view>

        <view class="flex bottom-fix ">
            <view class="cu-bar bg-gradual-orange half-width justify-center" style="width: 100%" @click="submite()">确定</view>
        </view>
    </view>
</template>

<script>
    export default {
        name: "AddPassenger",
		data(){
			return {
				name:'',
				icCard:'',
				id:''
			}
		},
		onLoad(e) {
			let that = this
			if(e.type!=1){			
				let data = JSON.parse(e.data)
				console.log(data)
				uni.setNavigationBarTitle({
					title: '修改乘车信息'
				})
				that.name = data.name
				that.icCard =data.id_card
				that.id = data.id
			}
		},
        methods: {
			submite(){
				let that = this
				if(that.name==''){
					that.tui.toast('姓名不能为空')
					return
				}
				if(that.icCard==''){
					that.tui.toast('身份证号不能为空')
					return
				}
				that.tui.request("api.auth.ticket/riderSet", "POST", {name:that.name,id_card:that.icCard,rider_id:that.id}, false, false, false).then((res) => {
					that.tui.toast(res.info)
					if (res.code == 1) {
						setTimeout(function(){
							uni.navigateBack()
						},1000)
					}
				}).catch((res) => {
				
				})
			},
        }
    }
</script>

<style scoped>

    .min-width75 {
        min-width: 75px;
    }
	.min-height40{
		min-height: 90rpx;
	}
</style>
